package com.coreservlets.jsf.ss12;

import com.coreservlets.jsf.ss06.RandomUtils;

public class TextGenerator
{
	private String[] colors = { "red", "yellow", "blue", "green" };
	
	private String[] phrases = { "Blah, blah, blah.", "Yadda, yadda, yadda.", "Foo, bar, baz." };
	
	public String getRandomColor()
	{
		return( colors[ new java.util.Random().nextInt(4)] );
	}
	
	public String getRandomText()
	{
		int numPhrases = 1 + RandomUtils.randomInt( 20 );
		
		String text = "";
		
		for (int i = 0; i < numPhrases; i++)
		{
			text += phrases[ new java.util.Random().nextInt( 3 ) ];
		}
		
		return( text );
	}
	
	public String getStartCell()
	{
		String text = String.format( "<th bgcolor='%s'>", getRandomColor() );
		
		return( text );
	}
	
	public String getEndCell()
	{
		return( "</th>" );
	}
}
